package com.example.demo.mapper;

import com.example.demo.entity.User;
import com.example.demo.entity.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from user where name=#{name}")
   User findByname(String name);

    @Select("select * from user")
    List<User> findAlll();

    @Insert("insert into user(id,name,pwd,last_login_ip,emails,tatus,last_login_time) values (#{id},#{name},#{pwd},#{lastLoginIP},#{email},#{status},#{lastLoginTime})")
    int register(User u);

    @Select("select * from user order by id desc limit 1 ")
    User selectLast();

    @Select("select * from user where name=#{name}")
    User selectByName(String name);

    @Select("select * from userinfo where name=#{name}")
    UserInfo selectByNames(String name);

    @Update("update user set email=#{email} where id=#{id}")
   int updateuser(String email,int id);

    @Update("update user set last_login_ip=#{lastLoginIP},last_login_time = now() where id=#{id}")
    int updateUserIPAndTime(String lastLoginIP, int id);
}
